Skip to content

feat: 新增 MediaPlayPause HotkeyTrigger 支持有线耳机线控录音 (#477)#568

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:feat/media-play-pause-trigger
Jun 1, 2026
Merged

feat: 新增 MediaPlayPause HotkeyTrigger 支持有线耳机线控录音 (#477)#568
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:feat/media-play-pause-trigger

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented May 31, 2026

User description

Closes #477

改动

在 HotkeyTrigger 枚举中新增 MediaPlayPause 变体,Windows WH_KEYBOARD_LL 钩子捕获 VK_MEDIA_PLAY_PAUSE(0xB3),使 EarPods 线控按钮可作为录音触发键。

Rust 后端

  • types.rs — 枚举变体、display_name、legacy_trigger_code、Windows available_triggers
  • hotkey.rs — Windows trigger_to_vk_code → 0xB3,macOS 占位
  • shortcut_binding.rs — legacy_modifier_trigger 字符串映射
  • coordinator.rs — window_key_matches_trigger → false
  • linux_fcitx.rs — 三处 sync 函数添加 MediaPlayPause 守卫避免配置迁移 panic

前端

  • types.ts — union 加 mediaPlayPause
  • hotkey.ts — legacyTriggerCode + formatPrimary
  • 5 个 i18n 文件加翻译

验证

  • cargo check 通过
  • 实测 EarPods 按钮在 Windows 11 上触发 0xB3

平台

  • ✅ Windows — 完整支持 Toggle / Hold / DoubleClick
  • ❌ macOS — 暂不支持(系统层拦截给 Siri)
  • ❌ Linux — 暂不支持

PR Type

Enhancement


Description

  • Add MediaPlayPause variant to HotkeyTrigger enum

  • Capture VK_MEDIA_PLAY_PAUSE (0xB3) on Windows via WH_KEYBOARD_LL

  • Frontend: extend types and i18n translations

  • Guards in Linux fcitx sync to avoid panic on Windows-only trigger


Diagram Walkthrough

flowchart LR
    MediaKey[EarPods Play/Pause Button] --> WH_KEYBOARD_LL[Windows Low Level Hook]
    WH_KEYBOARD_LL --> Trigger[HotkeyTrigger::MediaPlayPause]
    Trigger --> Recording[Toggle / Hold / DoubleClick Recording]
Loading

File Walkthrough

Relevant files
Bug fix
1 files
coordinator.rs
Skip window key fallback for MediaPlayPause                           
+2/-0     
Enhancement
5 files
hotkey.rs
Map MediaPlayPause to VK_MEDIA_PLAY_PAUSE on Windows         
+4/-0     
shortcut_binding.rs
Map legacy trigger strings and primary for MediaPlayPause
+2/-0     
types.rs
Add MediaPlayPause variant and display name                           
+4/-0     
hotkey.ts
Handle MediaPlayPause in legacy trigger and formatting     
+3/-0     
types.ts
Add mediaPlayPause to HotkeyTrigger union type                     
+1/-0     
Error handling
1 files
linux_fcitx.rs
Add guards for MediaPlayPause in fcitx sync functions       
+11/-1   
Internationalization
5 files
en.ts
Add MediaPlayPause translation for English                             
+1/-0     
ja.ts
Add MediaPlayPause translation for Japanese                           
+1/-0     
ko.ts
Add MediaPlayPause translation for Korean                               
+1/-0     
zh-CN.ts
Add MediaPlayPause translation for Simplified Chinese       
+1/-0     
zh-TW.ts
Add MediaPlayPause translation for Traditional Chinese     
+1/-0     

- 枚举新增 MediaPlayPause 变体,与 RightControl 等并列
- Windows WH_KEYBOARD_LL 钩子捕获 VK_MEDIA_PLAY_PAUSE (0xB3)
- macOS/Linux 标记为 unreachable (Windows-only)
- 前端类型、i18n 翻译支持
- 配置迁移保护:Linux fcitx 函数添加 MediaPlayPause 守卫

Closes Open-Less#477
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

477 - Partially compliant

Compliant requirements:

  • 新增 MediaPlayPause HotkeyTrigger,使有线耳机线控按钮可作为录音触发键(Windows 平台支持 Toggle / Hold / DoubleClick 模式)

Non-compliant requirements:

(无)

Requires further human verification:

  • 用户可能期望该功能默认启用(即无需在设置中选择),但 PR 将其作为可选项添加,需人工确认是否符合原始需求。
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit 4d2a35d into Open-Less:beta Jun 1, 2026
5 checks passed
@H-Chris233 H-Chris233 deleted the feat/media-play-pause-trigger branch June 1, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

建议:电脑连接有线耳机,期望长按耳机话筒后就可以录音从开结束

1 participant